package cqrtplm.controller;

import com.github.pagehelper.PageInfo;
import com.hustcad.plm.pdm.file.service.TyplmFileService;
import com.ty.basic.response.ResponseResult;
import cqrtplm.constant.RouteConstant;
import cqrtplm.dto.KnowledgePushDTO;
import cqrtplm.dto.RTAttributeCardDTO;
import cqrtplm.dto.RtCustomerNodeInfoDTO;
import cqrtplm.entity.RTDescribeInformationDO;
import cqrtplm.entity.RtCustomerNodeInfoDO;
import cqrtplm.service.RTKnowledgePushService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "知识推送管理")
@RequestMapping(RouteConstant.KNOWLEDGEPUSH + "v1")
public class RTKnowledgePushController {

    @Resource
    private RTKnowledgePushService rtKnowledgePushService;
    @Resource
    private TyplmFileService typlmFileService;

    @PostMapping("/addKnowledgeInfo")
    @ApiOperation(value = "新增知识推送", produces = "application/json; charset=utf-8")
    public ResponseResult<RtCustomerNodeInfoDO> addKnowledgeInfo(@RequestBody RtCustomerNodeInfoDTO customerNodeInfoDTO) {
        return rtKnowledgePushService.addKnowledgeInfo(customerNodeInfoDTO);
    }

    @PutMapping("/updateKnowledgeInfo")
    @ApiOperation(value = "更新知识推送", produces = "application/json; charset=utf-8")
    public ResponseResult<T> updateKnowledgeInfo(@RequestBody RtCustomerNodeInfoDTO customerNodeInfoDTO) {
        rtKnowledgePushService.updateKnowledgeInfo(customerNodeInfoDTO);
        return ResponseResult.success();
    }

    @DeleteMapping("/deleteKnowledgeInfoByOid")
    @ApiOperation(value = "批量删除知识推送", produces = "application/json; charset=utf-8")
    public ResponseResult<T> batchDeleteKnowledgeInfo(@RequestBody List<String> Oids) {
        rtKnowledgePushService.batchDeleteKnowledgeInfo(Oids);
        return ResponseResult.success();
    }

    @GetMapping("/search-text")
    @ApiOperation(value = "查询文本推送信息")
    public ResponseResult<PageInfo<RtCustomerNodeInfoDTO>> searchText(
            @RequestParam(required = false) String customer,
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "20") int pageSize) {
        PageInfo<RtCustomerNodeInfoDTO> pageInfo = rtKnowledgePushService.searchTextByCustomer(customer, pageNum, pageSize);
        return ResponseResult.success(pageInfo);
    }

    @GetMapping("/search-file")
    @ApiOperation(value = "查询文件推送信息")
    public ResponseResult<PageInfo<RtCustomerNodeInfoDTO>> searchFile(
            @RequestParam(required = false) String customer,
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "20") int pageSize) {
        PageInfo<RtCustomerNodeInfoDTO> pageInfo = rtKnowledgePushService.searchFileByCustomer(customer, pageNum, pageSize);
        return ResponseResult.success(pageInfo);
    }





}
